package com.easyweb.entity;

import java.io.Serializable;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.GeneratedValue;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Version;
import org.hibernate.validator.Length;
import org.hibernate.validator.NotNull;

@Entity
@NamedQueries( {
	@NamedQuery(name = "semtlerTumKayitlarIleGore", query = "select s from Semtler s where s.ilce.id=:p1 order by s.semtAdi") 
})
@Table
public class Semtler implements Serializable {
	@Id
	@GeneratedValue
	private Long id;
	@Version
	private Integer version;

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "ilceId")
	private Ilce ilce;

	@Column(length = 50)
	@Length(max = 50, message = "#{messages.errUzunlukElliGecemez}")
	@NotNull(message = "#{messages.errBosOlamaz}")
	private String semtAdi;
	
	@OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL, mappedBy = "semt")
	private List<Bayi> bayiler;
	
	public Semtler() {

	}

	public Semtler(Long id, Integer version, Ilce ilce, String semtAdi) {
		super();
		this.id = id;
		this.version = version;
		this.ilce = ilce;
		this.semtAdi = semtAdi;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Integer getVersion() {
		return version;
	}

	public void setVersion(Integer version) {
		this.version = version;
	}

	public Ilce getIlce() {
		return ilce;
	}

	public void setIlce(Ilce ilce) {
		this.ilce = ilce;
	}

	public String getSemtAdi() {
		return semtAdi;
	}

	public void setSemtAdi(String semtAdi) {
		this.semtAdi = semtAdi;
	}

	public List<Bayi> getBayiler() {
		return bayiler;
	}

	public void setBayiler(List<Bayi> bayiler) {
		this.bayiler = bayiler;
	}

 

}
